package org.lsy;

import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.lsy.component.TaskA;
import org.lsy.component.TaskB;
import org.lsy.component.TaskC;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.concurrent.*;


/**
 * @author liusy95
 * @version 1.0
 * @date 2020/7/2
 */
public class ConsumeMain {



    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 20, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<>(100), new ThreadPoolExecutor.DiscardPolicy());
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        TaskA taskA = context.getBean(TaskA.class);
        TaskB taskB = context.getBean(TaskB.class);
        TaskC taskC = context.getBean(TaskC.class);
        while (true) {
            executor.execute(taskA);
            executor.execute(taskB);
            executor.execute(taskC);
        }
    }

    @Configuration
    @EnableDubbo
    @ComponentScan(basePackages = "org.lsy.component")
    @PropertySource("classpath:/dubbo-consumer.properties")
    static class ConsumerConfiguration {
    }
}
